<?php

use Phinx\Migration\AbstractMigration;

class CreateBlackCardSubBalanceLog extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('black_card_sub_balance_log');
        $table->addColumn('sub_card_id', 'integer', ['comment' => '子卡ID'])
            ->addColumn('type', 'integer', ['limit' => 1, 'comment' => '类型：1=充值，2=消费'])
            ->addColumn('amount', 'decimal', ['precision' => 12, 'scale' => 2, 'default' => '0.00', 'comment' => '金额'])
            ->addColumn('before_balance', 'decimal', ['precision' => 12, 'scale' => 2, 'default' => '0.00', 'comment' => '变动前余额'])
            ->addColumn('after_balance', 'decimal', ['precision' => 12, 'scale' => 2, 'default' => '0.00', 'comment' => '变动后余额'])
            ->addColumn('remark', 'string', ['limit' => 255, 'null' => true, 'comment' => '备注'])
            ->addColumn('created_at', 'timestamp', ['null' => true])
            ->addColumn('updated_at', 'timestamp', ['null' => true])
            ->addIndex(['sub_card_id'])
            ->addIndex(['type'])
            ->create();
    }
} 